package com.itheima.a01mathdemo;

public class MathDemo2 {
    public static void main(String[] args) {
        //判断一个数是否为一个质数
        int number = 13;
        if (isPrime(number)) {
            System.out.println(number + "是质数");
        } else {
            System.out.println(number + "不是质数");
        }
    }

    public static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
